package cn.bdqn.dao;

import cn.bdqn.pojo.Bank;
import cn.bdqn.pojo.Test;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: 苏闻君
 * @Date: Created in 2020/7/16  20:35
 */
@Mapper
public interface TestDaok {
    /**
     * 查询所有试卷
     * @return
     */
    @Select("SELECT id,testname FROM test;")
    List<Test> list();

    /**
     * 查询单选试题
     * @param id
     * @return
     */
    @Select("SELECT  bank.`column` AS columnss,test.`id` AS testid,test.`testname` AS testname,bank.* FROM bank LEFT JOIN kfw tb ON tb.`bankid`=bank.`id` LEFT JOIN test ON test.`id`=tb.`testid` WHERE test.`id`=#{id} AND bank.`type`=1 AND bank.`column` BETWEEN 1 AND 50")
    List<Bank> test(Integer id);

    /**
     * 查询多选题
     * @param id
     * @return
     */
    @Select("SELECT  bank.`column` AS columnss,test.`id` AS testid,test.`testname` AS testname,bank.* FROM bank LEFT JOIN kfw tb ON tb.`bankid`=bank.`id` LEFT JOIN test ON test.`id`=tb.`testid` WHERE test.`id`=#{id} AND bank.`type`=2 AND bank.`column` BETWEEN 1 AND 20 ORDER BY bank.`column` ASC")
    List<Bank> testMore(Integer id);
}
